package com.oppo.action;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oppo.bean.ProductBean;
import com.oppo.service.impl.ProductAddInfoService;
import com.oppo.tools.MyTools;

@WebServlet("/ProductAddInfoControl")
@MultipartConfig(maxFileSize=1024*1024*5) // 计算的基本单位是字节（byte）
public class ProductAddInfoControl extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		ProductBean two = MyTools.formToBean_WithFile(request, ProductBean.class);
		int i = MyTools.getNewInstance(ProductAddInfoService.class).AddInfo(two);
		if(i > 0) {
			MyTools.logRootLogger.info("商品信息添加成功！");
			response.sendRedirect("ProductAddInfo.jsp");
		}else {
			response.sendRedirect("ProductAddInfo.jsp");
			MyTools.logRootLogger.info("商品信息添加失败！");
		}
		MyTools.logRootLogger.info("时间：" + MyTools.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss"));
	}

}
